package com.w3cjava.modules.index.controller;

import com.w3cjava.common.properties.ConfigurationPropertiesBeans;
import com.w3cjava.common.properties.CustomProperties;
import com.w3cjava.common.properties.W3cjavaConfigBean;
import com.w3cjava.modules.index.bean.XmlBeanTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private CustomProperties customProperties;

    // 1.

    @RequestMapping("/custom-properties")
    public String customProperties() {
        return customProperties.getName() + ":" + customProperties.getDesc() + ":" + customProperties.getTitle();
    }
    // 2.
    @Autowired
    private XmlBeanTest xmlBeanTest;
    //自定义配置文件echoplots.properties Test
    @RequestMapping("/xml")
    public String xml() {
        return xmlBeanTest.getName();
    }

    // 3.
    @Autowired
    private ConfigurationPropertiesBeans configurationPropertiesBeans;
    //多自定义属性Test
    @RequestMapping("/bean")
    public String indexBean() {
        return configurationPropertiesBeans.getName()+"###" +configurationPropertiesBeans.getDesc();
    }


    //属性间引用Test
    @RequestMapping("/title")
    public String title() {
        return configurationPropertiesBeans.getTitle();
    }

    // 4.
    @Autowired
    private W3cjavaConfigBean w3cjavaConfigBean;
    @RequestMapping("/properties")
    public String properties() {
        return "姓名："+w3cjavaConfigBean.getName()+" 年龄："+w3cjavaConfigBean.getAge();
    }
}
